<?php 
namespace Zbsht\Controller;



class UserController extends CommentController {


	public function index(){

		// $data = D('user')->select();

		// print_r($data);exit;
		// echo $this->ajaxReturn($data);

		if (IS_AJAX) {
			
			$data = D('user')->order('id desc')->limit(I('page')==1?1:I('page')*10-10,I('limit'))->select();
			$res = [
				'code' => 0,
				'msg' => '',
				'count' => D('user')->count(),
				'data' => $data,
			];
			echo json_encode($res);
		}else{

			$this->display('list');
		}
	}


	public function userform(){

		if (IS_AJAX && IS_POST) {
			$post = I('post.');
			$post['password']  = md5($post['password']);
			$post['create_time']  = time();
			$post['create_ip']  = get_real_ip();


			$res = D('user')->add($post);
			if ($res) {
				return $this->success('添加成功！');
			}else{
				return $this->error('添加失败！');
			}
		}else{

			$this->display();
		}
	}





}





















?>